import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/normalize.min.css'
import './assets/iconfont/iconfont.css'


import { Form, Input, FormItem, Button, Message, Container, Header, Aside, Main, Menu, Submenu, MenuItem, Breadcrumb, BreadcrumbItem, Table, TableColumn, Row, Col, Switch, Pagination, Card, Dialog, MessageBox, Tag, Tooltip, Tree, Select, Option, Cascader, Alert, Tabs, TabPane, Steps, Step, Checkbox, CheckboxGroup, Upload, Timeline, TimelineItem } from 'element-ui';
// import 'element-ui/lib/theme-chalk/index.css';
Vue.use(Input);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Button);
Vue.prototype.$message = Message
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Menu);
Vue.use(Submenu);
Vue.use(MenuItem);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(Row);
Vue.use(Col);
Vue.use(Switch);
Vue.use(Pagination);
Vue.use(Card);
Vue.use(Dialog);
Vue.use(Tag);
Vue.use(Tooltip);
Vue.use(Tree);
Vue.use(Select);
Vue.use(Option);
Vue.use(Cascader);
Vue.use(Alert);
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Steps);
Vue.use(Step);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Upload);
Vue.use(Timeline);
Vue.use(TimelineItem);
Vue.prototype.$confirm = MessageBox.confirm


//使用nprogress进度条插件
import NProgress from 'nprogress';
// import 'nprogress/nprogress.css'

//处理axios
import axios from 'axios';
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config => {
    nProgress.start() //发起请求前开始进度条
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
})
axios.interceptors.response.use(config => {
    nProgress.done() //响应成功前隐藏进度条
    return config
})
Vue.prototype.$http = axios

//使用树形表格插件
import TreeTable from 'vue-table-with-tree-grid'
Vue.component("TreeTable", TreeTable)

//使用富文本编辑器插件
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
import nProgress from 'nprogress'
Vue.use(VueQuillEditor, /* { default global options } */ )

//注册全局时间过滤器
Vue.filter('dateFmt', function(dateVal) {
    const date = new Date(dateVal)
    const y = date.getFullYear()
    const m = (date.getMonth() + 1 + '').padStart(2, '0') //转成字符串,判断不足两位在前面加0
    const d = (date.getDate() + '').padStart(2, '0')

    const hh = (date.getHours() + '').padStart(2, '0')
    const mm = (date.getMinutes() + '').padStart(2, '0')
    const ss = (date.getSeconds() + '').padStart(2, '0')

    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.config.productionTip = false

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')